<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://amc.af.mil/portal-el" prefix="portal" %>
<%@ taglib uri="http://amc.af.mil/radtaglibrary" prefix="rad" %>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<%@ taglib prefix="display" uri="http://displaytag.sf.net" %>
<%@ taglib uri="http://struts.apache.org/tags-html-el" prefix="html" %>
<html>
<head>
    <title>Equipment Report</title>
</head>

<body>

<rad:useBean id="equipmentItemViewHelper"/>
<rad:useBean id="adpeAccountViewHelper"/>
<rad:useBean id="equipmentTypeViewHelper"/>
<rad:useBean id="manufacturerViewHelper"/>

<div id="portal-left-bar">
    <jsp:include page="../navigation/navigationMenu.jsp"/>
</div>

<div id="portal-content">
    <portal:box title="Assigned Equipment" style="width:800px">
        <portal:subSection title="Account">
            <html:form method="post" action="report/equipmentReportSelector">
                <table style="width: 100%">
                    <thead>
                        <tr>
                            <th>ADPE Account</th>
                            <th>Equipment Type</th>
                            <th>Manufacturer</th>
                            <th>&nbsp;</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr style="text-align: center">
                            <td>
                                <html:select property="adpeAccountId" styleId="adpeAccountId"
                                             value="${requestScope.adpeAccountId}">
                                    <html:option value="-1">All</html:option>
                                    <html:optionsCollection name="adpeAccountViewHelper"
                                                            property="adpeAccountsByAccount"
                                                            label="name"
                                                            value="id"/>
                                </html:select>
                            </td>
                            <td>
                                <html:select property="equipmentTypeId" styleId="equipmentTypeId"
                                        value="${requestScope.equipmentTypeId}">
                                    <html:option value="-1">All</html:option>
                                    <html:optionsCollection name="equipmentTypeViewHelper"
                                                            property="all"
                                                            label="name"
                                                            value="id"/>
                                </html:select>
                            </td>
                            <td>
                                <html:select property="manufacturerId" styleId="manufacturerId"
                                        value="${requestScope.manufacturerId}">
                                    <html:option value="-1">All</html:option>
                                    <html:optionsCollection name="manufacturerViewHelper"
                                                            property="all"
                                                            label="name"
                                                            value="id"/>
                                </html:select>
                            </td>
                            <td><html:submit value="View" /></td>
                        </tr>
                    </tbody>
                </table>
            </html:form>
        </portal:subSection>
        <portal:subSection title="Inventory">
            <display:table name="equipmentItemViewHelper.allByAdpeAccountAndEquipmentTypeAndManufacturer"
                           id="item"
                           style="width: 100%">
                <%--<display:column property="equipmentType" title="Type"/>--%>
                <display:column title="Manufacturer" style="text-align: center;" sortable="true"
                                comparator="mil.af.amc.adpetracker.model.comparators.EquipmentItemManufacturerComparator">
                    <c:out value="${item.itemModel.manufacturer.name}"/>
                </display:column>
                <display:column title="Model" style="text-align: center;" sortable="true"
                        comparator="mil.af.amc.adpetracker.model.comparators.EquipmentItemModelComparator">
                    <c:out value="${item.itemModel.name}"/>
                </display:column>
                <display:column title="Description" style="text-align: center;">
                    <c:out value="${item.itemModel.type.name}"/>
                </display:column>
                <display:column title="Serial">
                    <c:out value="${item.serial}" />
                </display:column>
                <display:column title="Assigned To">
                    <c:choose>
                        <c:when test="${item.assignedUser.displayName ne null}">
                            <c:out value="${item.assignedUser.displayName}"/>
                        </c:when>
                    </c:choose>
                </display:column>
                <display:column title="Actions">
                    <a href="equipmentItemAction.do?method=viewItemPage&itemId=<c:out value="${item.id}" />">View
                        Item</a>
                </display:column>
            </display:table>
        </portal:subSection>
    </portal:box>
</div>
</body>
</html>